
package com.erhirent.view;

import java.util.InputMismatchException;

import com.erhairent.tools.InputTools;

public class MainView extends View {

	@Override
	public View showView() {
		System.out.println("*********************");
		System.out.println("欢迎访问二嗨租车");
		System.out.println("*********************");
		System.out.println("1.登陆\t\t" + "2.注册\t\t" + "3.退出\t\t");
		System.out.println("请选择数字:");
		choose();
		return mView;
	}

	// 判断是否输入正确
	public void choose() {
		int chooseNum;
		while (true) {
			try {
				chooseNum = InputTools.nextInt();
				if (chooseNum < 1 || chooseNum > 3) {
					System.out.println("没有该选项,重新输入");
					continue;
				}
				break;
			} catch (InputMismatchException e) {
				System.out.println("没有该选项,请重新输入");
				InputTools.nextInt();
			}
		}
		switch (chooseNum) {
		case 1:
			mView = new loginView();
			break;
		case 2:
			mView = new registerView();
			break;
		case 3:
			System.out.println("欢迎下次光临!");
			break;
		default:
			break;
		}

	}

}